1 //Header Files
2 #include <iostream>
3 #include <fstream>
4 #include <conio.h>
5 #include <
string>
6 #include <math.h>
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <process.h>
10 #include <time.h>

11 using
namespace std;
12
13 //Class definition
for ticket
14 class
ticket{
15     
public:
16     
char name[10];
17     
char cno[10];
18 } t;
//object definition for ticket
19
20 // Class definition
for card
21 class
card : public ticket{ //inheritence for public ticket
22 public
:
23     
char address[50];
24     
char emailid[20];
25 } v;
//object definition for card
26
27 //Prototype Call
for the functions definitions.
28 void
pay(int);
29 void
random();
30 void
card();
31
32 //Main function

33 int
main(){
34     system(
"CLS");
35     
//Integer Declaration
36     
int ent, a, b, N, x, cardid;
37     
char ans;
38     
//To display the system time.
39     
//Using time header file
40     {time_t t = time(NULL);
41     tm* timePtr = localtime(&t);
42     cout <<
"Time of the computer presently:";
43     cout <<
"seconds= " << timePtr->tm_sec << endl;
44     cout <<
"minutes = " << timePtr->tm_min << endl;
45     cout <<
"hours = " << timePtr->tm_hour << endl;
46     cout <<
"day of month = " << timePtr->tm_mday << endl;
47     cout <<
"month of year = " << timePtr->tm_mon << endl;
48     cout <<
"year = " << timePtr->tm_year + 1900 << endl;
49     cout <<
"weekday = " << timePtr->tm_wday << endl;
50     cout <<
"day of year = " << timePtr->tm_yday << endl;
51     cout <<
"daylight savings = " << timePtr->tm_isdst << endl;
52     }
53     
54     
//An exit controlled loop (Do...While)
55     
do{
56         
//Menu
57         cout<<
"\n\t\t\t ----------------------------------";
58         cout<<
"\n\t\t\t Simple Movie Ticket Booking System";
59         cout<<
"\n\t\t\t ----------------------------------";
60         cout<<
"\n\t\t\t\t Welcome Customer!"; //Menu for the user
61         cout<<
"\n\n\t\t\t\t <1> Movie Timings";
62         cout<<
"\n\t\t\t\t <2> Recieving Ticket";
63         cout<<
"\n\t\t\t\t <3> For Information";
64         cout<<
"\n\t\t\t\t <4> DTCard Registration";
65         cout<<
"\n\t\t\t\t <5> Exit \n\n";
66         cout<<
"\t\t\t\tEnter Your Choice :"<<"\t";
67         cin>>ent;
68     
switch(ent)
69     {
70             
//Movie Titles
71         
case 1:
72         system(
"CLS");
73         cout<<
"\n\n\t\t\t\tThe Shows are :";
74             cout<<
"\n\n\t\t\t\t 1. Avengers: Infinity War";
75             cout<<
"\n\n\t\t\t\t 2. Antman And The Wasp";
76             cout<<
"\n\n\t\t\t\t 3. Deadpool 2";
77             cout<<
"\n\n\t\t\t\t 4. Venom";
78             cout<<
"\n\n\t\t\t\t 5. Captain Marvel\n";
79             cout<<
"\n\t\t\t\tEnter Your Choice :"<<"\t";
80             cin>>a;
81             cout<<
"\n\n\t\t\t\t The Timings for the selected show are:";
82             
switch(a)
83             {
84                 
case 1:
85                     system(
"CLS");
86                  cout<<
"\n\n\t\t\t\t Select the the timings: ";
87                     cout<<
"\n\t\t\t\t 1. 0800";
88                     cout<<
"\n\t\t\t\t 2. 1300";
89                     cout<<
"\n\t\t\t\t 3. 1450";
90                     cout<<
"\n\t\t\t\t 4. 1800";
91                     cout<<
"\n\t\t\t\t 5. 2100";
92                     cout<<
"\n\t\t\t\t 6. 0100 \n"; //Timings of the show
93                     cout<<
"\n\n\t\t\t\t Please select the timings: ";
94                     cin>>b;
95                     cout<<
"\n\n\t\t\t\t Enter your name: ";
96                     cin>>t.name;
97                     cout<<
"\n\n\t\t\t\t Enter your contact number: ";
98                     cin>>t.cno;
99                     cout<<
"\n\n\t\t\t\t Enter the number of tickets you want to purchase: ";
100                     
int x;
101                     cin>>x;
102                     pay(x);
103                     cout<<
"\n\n\n\t\t\t\t Your ticket is here: ";
104                     cout<<
"\n\t\t\t\t Name :"<<t.name;
105                     cout<<
"\n\t\t\t\t Contact No :"<<t.cno;
106                     cout<<
"\n\t\t\t\t Show timings :";
107                     
switch(b)
108                         {
109                             
case 1: cout<<"0800";
110                                 
break;
111                             
case 2: cout<<"1300";
112                                 
break;
113                             
case 3: cout<<"1450";
114                                 
break;
115                             
case 4: cout<<"1800";
116                                 
break;
117                             
case 5: cout<<"2100";
118                                 
break;
119                             
case 6: cout<<"0100";
120                                 
break;
121                         }
122                         cout<<
"\n\n\t\t\t\t Do you want to choose another option(y/n)";
123                         cin>>ans;
124                         system(
"CLS");
125                         
break;
126                 
case 2:
127                 system(
"CLS");
128                 cout<<
"\n\n\t\t\t\tSelect the the timings:";
129                     cout<<
"\n\t\t\t\t 1. 0900";
130                     cout<<
"\n\t\t\t\t 2. 1100";
131                     cout<<
"\n\t\t\t\t 3. 1250";
132                     cout<<
"\n\t\t\t\t 4. 1500";
133                     cout<<
"\n\t\t\t\t 5. 2000";
134                     cout<<
"\n\t\t\t\t 6. 2200";
135                     cout<<
"\n\t\t\t\t Please select the timings: ";
136                     cin>>b;
137                     cout<<
"\n\n\t\t\t\t Enter your name: ";
138                     cin>>t.name;
139                     cout<<
"\n\t\t\t\t Enter your contact number: ";
140                     cin>>t.cno;
141                     cout<<
"\n\t\t\t\t Enter the number of tickets you want to purchase: ";
142                     cin>>x;
143                     pay(x);
144                     cout<<
"\n\n\t\t\t\t Your ticket is here:";
145                     cout<<
"\n\t\t\t\t Name :"<<t.name;
146                     cout<<
"\n\t\t\t\t Contact No :"<<t.cno;
147                     cout<<
"\n\t\t\t\tShow timings :";
148                     
switch(b)
149                     {
150                             
case 1: cout<<"0800";
151                                 
break;
152                             
case 2: cout<<"1300";
153                                 
break;
154                             
case 3: cout<<"1450";
155                                 
break;
156                             
case 4: cout<<"1800";
157                                 
break;
158                             
case 5: cout<<"2100";
159                                 
break;
160                             
case 6: cout<<"0100";
161                                 
break;
162                     }
163                     cout<<
"\n\n\t\t\t\t Do you want to choose another option(y/n)";
164                     cin>>ans;
165                     system(
"CLS");
166                     
break;
167                 
case 3:
168                 system(
"CLS");
169                 cout<<
"\n\n\t\t\t\tSelect the the timings:";
170                     cout<<
"\n\t\t\t\t 1. 0800";
171                     cout<<
"\n\t\t\t\t 2. 1300";
172                     cout<<
"\n\t\t\t\t 3. 1450";
173                     cout<<
"\n\t\t\t\t 4. 1800";
174                     cout<<
"\n\t\t\t\t 5. 2100";
175                     cout<<
"\n\t\t\t\t 6. 0100";
176                     cout<<
"\n\t\t\t\t Please select the timings";
177                     cin>>b;
178                     cout<<
"\n\t\t\t\t Enter your name: ";
179                     cin>>t.name;
180                     cout<<
"\n\t\t\t\t Enter your contact number: ";
181                     cin>>t.cno;
182                     cout<<
"\n\t\t\t\tEnter the number of tickets you want to purchase: ";
183                     cin>>x;
184                     pay(x);
185                     cout<<
"\n\n\t\t\t\t Your ticket is here: ";
186                     cout<<
"\n\t\t\t\t Name :"<<t.name;
187                     cout<<
"\n\t\t\t\t Contact No :"<<t.cno;
188                     cout<<
"\n\t\t\t\t Show timings :";
189                     
switch(b)
190                     {
191                             
case 1: cout<<"0900";
192                                 
break;
193                             
case 2: cout<<"1300";
194                                 
break;
195                             
case 3: cout<<"1450";
196                                 
break;
197                             
case 4: cout<<"1800";
198                                 
break;
199                             
case 5: cout<<"2100";
200                                 
break;
201                             
case 6: cout<<"0100";
202                                 
break;
203                     }
204                     cout<<
"\n\n\t\t\t\t Do you want to choose another option(y/n)";
205                     cin>>ans;
206                     system(
"CLS");
207                     
break;
208                 
case 4:
209                 system(
"CLS");
210                 cout<<
"\n\n\t\t\t\tSelect the the timings: ";
211                     cout<<
"\n\t\t\t\t 1. 0800";
212                     cout<<
"\n\t\t\t\t 2. 1300";
213                     cout<<
"\n\t\t\t\t 3. 1450";
214                     cout<<
"\n\t\t\t\t 4. 1800";
215                     cout<<
"\n\t\t\t\t 5. 2100";
216                     cout<<
"\n\t\t\t\t 6. 0100";
217                     cout<<
"\n\t\t\t\t Please select the timings: ";
218                     cin>>b;
219                     cout<<
"\n\t\t\t\t Enter your name: ";
220                     cin>>t.name;
221                     cout<<
"\n\t\t\t\t Enter your contact number: ";
222                     cin>>t.cno;
223                     cout<<
"\n\t\t\t\t Enter the number of tickets you want to purchase: ";
224                     cin>>x;
225                     pay(x);
226                     cout<<
"\n\n\t\t\t\t Your ticket is here: ";
227                     cout<<
"\n\t\t\t\t Name :"<<t.name;
228                     cout<<
"\n\t\t\t\t Contact No :"<<t.cno;
229                     cout<<
"\n\t\t\t\t Show timings :";
230                     
switch(b)
231                     {
232                             
case 1: cout<<"0800";
233                                 
break;
234                             
case 2: cout<<"1300";
235                                 
break;
236                             
case 3: cout<<"1450";
237                                 
break;
238                             
case 4: cout<<"1800";
239                                 
break;
240                             
case 5: cout<<"2100";
241                                 
break;
242                             
case 6: cout<<"0100";
243                                 
break;
244                     }
245                         cout<<
"\n\n\t\t\t\t Do you want to choose another option(y/n)";
246                         cin>>ans;
247                         system(
"CLS");
248                         
break;
249                 
case 5:
250                 system(
"CLS");
251                 cout<<
"\n\n\t\t\t\tSelect the the timings:";
252                     cout<<
"\n\t\t\t\t 1. 0800";
253                     cout<<
"\n\t\t\t\t 2. 1300";
254                     cout<<
"\n\t\t\t\t 3. 1450";
255                     cout<<
"\n\t\t\t\t 4. 1800";
256                     cout<<
"\n\t\t\t\t 5. 2100";
257                     cout<<
"\n\t\t\t\t 6. 0100";
258                     cout<<
"\n\t\t\t\t Please select the timings: ";
259                     cin>>b;
260                     cout<<
"\n\t\t\t\t Enter your name: ";
261                     cin>>t.name;
262                     cout<<
"\n\t\t\t\t Enter your contact number: ";
263                     cin>>t.cno;
264                     cout<<
"\n\t\t\t\t Enter the number of tickets you want to purchase: ";
265                     cin>>x;
266                     pay(x);
267                     cout<<
"\n \n\t\t\t\t Your ticket is here: ";
268                     cout<<
"\n\t\t\t\t Name :"<<t.name;
269                     cout<<
"\n\t\t\t\t Contact No :"<<t.cno;
270                     cout<<
"\n\t\t\t\t Show timings :";
271                     
switch(b)
272                     {
273                             
case 1: cout<<"0800";
274                                 
break;
275                             
case 2: cout<<"1300";
276                                 
break;
277                             
case 3: cout<<"1450";
278                                 
break;
279                             
case 4: cout<<"1800";
280                                 
break;
281                             
case 5: cout<<"2100";
282                                 
break;
283                             
case 6: cout<<"0100";
284                                 
break;
285                     }
286                     cout<<
"\n\n\t\t\t\t Do you want to choose another option(y/n)";
287                     cin>>ans;
288                     system(
"CLS");
289                     
break;
290             }
break;
291         
case 2: system("CLS");
292                 cout<<
"\n\nThank you for booking the tickets online \n To print out the tickets please enter your transaction ID in the portal"; //Finding about a prebooked ticket
293                 
struct pre
294                 {
295                 
int trsnid;
296                 
char name[10];
297                 } p;
298                 cout<<
"\n Enter your transaction id\n (Eg.last five digits of the transaction id) ";
299                 cin>>p.trsnid;
300                 cout <<
"Enter your name";
301                 cin>>p.name;
302                 cout<<
"Sorry to say that but you will need to get the print out of the booking because our database shows no booking by this name";
303                 cout<<
"\n Do you want to choose another option(y/n)";
304                 cin>>ans;
305                 system(
"CLS");
306                 
break;
307         
case 3: system("CLS");
308                 cout<<
"For further information about movies you can download our Application(from the Google Play Store or from the iOS App Store) or contact us at 01234567896523"; //Finding out more about our cinemas
309                 cout<<
"\n Do you want to choose another option(y/n)";
310                 cin>>ans;
311                 system(
"CLS");
312                 
break;
313         
case 4: system("CLS");
314                 cout<<
"Good Morning/Evnening \n Welcome to start a new journey with our cinemas \n"; //card membership
315                 card();
316                 cout<<
"Thankyou. \n It will take us a week for completing your registration for the card. \n Please see the benefits of the card on the next page. -->";
317                 
char f;
318                 cout<<
"\n For selecting the page to go to benefits say (y/n)\n";
319                 cin>>f;
320                 
if(f=='y')
321                 {
322                     cout<<
"Thank you for registeration once again \n The priveleges provided with this card are as follows:";
323                     cout<<
"\n 1. For every purchase of a movie ticket you get 25 points(1point = 1Rs.) so after 16 movies you get a free movie ticket.";
324                     cout<<
"\n 2. You are provided with regular updates regarding the movie and the showtimings.";
325                     cout<<
"\n 3. Anytime prebook tickets for the upcoming movie and preffered seats will be provided.";
326                 }
327                 cout<<
"\n Do you want to choose another option(y/n)";
328                 cin>>ans;
329                 
if(ans=='y')
330                 {
331                     system(
"CLS");
332                     
break;
333                 }
334                 
else
335                 {
336                     exit(
0);
337                 }
338                 
break;
339         
case 5:
340         system(
"CLS");
341         cout<<
"\n\t\t\t\tBrought To You by code-projects.org\n\n\t\t\t\t";
342         system(
"PAUSE");
343         exit(
0);
344                 
break;
345     }
346     }
while(ans=='y');
347     }

348
349 //Function Declaration
for Card
350 void
card()
351 {
352     
int cardid;
353     cout<<
"\t\t\t\tWelcome to register for card facility in our cinemas";
354     cout<<
" \n\t\t\t\t Enter your name: ";
355     cin>>v.name;
356     cout<<
"\t\t\t\tEnter your mobile number: ";
357     cin>>v.cno;
358     cout<<
"\t\t\t\tEnter the address: ";
359     gets(v.address);
360     cout<<
"\t\t\t\tEnter the mail id: ";
361     gets(v.emailid);
362     system(
"CLS");
363     
int ID;
364     srand (time(NULL));
365     ID = rand() %
400000 + 4000000;
366     
if (ID<0)
367     ID=(ID*-
1);
368     cout<<
"\t\t\t\tYour new card number is - :" <<"\t"<<ID;
369     fstream fout;
370     fout.open(
"card.dat", ios::out|ios::app);
371     fout<<
"\n Name :"<<v.name<<"\n"<<"\n Mobile No. :"<<v.cno<<"\n"<<"\n Address :"<<v.address<<"\n"<<"\n Mail ID :"<<v.emailid<<"\n"<<"\nCard Number:"<<ID;
372     fout.close();
373     cout<<
"\t\t\t\tThank you for the registeration for the card. \n";
374 }

375
376 //Payment system
for the interface
377 void
pay(int a)
378 {
379     
int normal, gold, amt[2],id;
380     time_t t = time(NULL);
//time setup
381     tm* timePtr = localtime(&t);
382     fstream fin;
383     fin.open(
"card.dat", ios::in|ios::app);
384     fin>>id;
385     cout<<
"\t\tThank you for selecting the show. Now we request you to select your type of seating \n\n\t\t\t\t 1.Normal Class \n\t\t\t\t OR \n\t\t\t\t 2. Gold Class";
386     
int c;
387     cin>>c;
388     
if(c==1)
389     {
390         cout<<
"\n\n\t\t\t\tYou selected for a Normal show \n\n\t\t\t\t";
391         system(
"PAUSE");
392         system(
"CLS");
393         amt[
1] = a * 400;
394         
char final;
395         cout<<
"\n\n\t\t\t\t Do you have DTcard(y/n): ";
396         cin>>final;
397         
if(final=='y')
398         {
399             
int cid;
400             fin.read((
char*) &v, sizeof(v));
401             
402             cout<<
"\n\t\t\t\tEnter the card number[10 digits]: ";
403             
404             
if(cid==id)
405             {
406                 amt[
1]=amt[1] - (0.1*amt[1]);
407             };
408         }
409         cout<<
"\n\t\t\t\tWant to pay by Card(y/n): ";
410         
char rep;
411         cin>>rep;
412         cout<<
"\n\t\t\t\t"<<"Paying :"<<amt[1]<<"\n";
413         
if (rep=='y'||rep=='Y')
414         {
415             cout<<
"\t\t\t\tName of the card holder: ";
416             
char n[10];
417             gets(n);
418             cout<<
"\n\t\t\t\tEnter the card number: ";
419             
char Card[16];
420             gets(Card);
421             cout<<
"\t\t\t\tExpiry(MM/YYYY)";
422             
int expirymm,expiryyy;
423             cin>>expirymm;
424             cout<<
"\t\t\t\t/";
425             cin>>expiryyy;
426             
while(expirymm<(timePtr->tm_mon) || expiryyy<(timePtr->tm_year + 1900)){
427                 
if(expirymm<=(timePtr->tm_mon))
428                     {
429                         cout<<
"\t\t\t\tEnter the month again: ";
430                         cin>>expirymm;
431                     }
432                 
if(expiryyy<(timePtr->tm_year + 1900))
433                 {
434                     cout<<
"\t\t\t\tPlease enter a valid year: ";
435                     cin>>expiryyy;
436                 }
437             };
438             
char password[3],vh;
439             
int h;
440             puts(
"\t\t\t\tEnter the CVV/CVV2: ");
441             
while (1)
442             {
443                 
if (h<0)
444                     h=
0;
445                 vh=getch();
446                 
if (vh==13)
447                     
break;
448                 
if (vh==8)
449                 {
450                     putch(NULL);
451                     putch(NULL);
452                     putch(NULL);
453                     h--;
454                     
continue;
455                 }
456                 password[h++]=vh;
457                 vh=
'*';
458                 putch(vh);
459             };
460             password[h]==
'\0';
461         }
462     }
463     
else
464     {
465         cout<<
"\n\n\t\t\t\tYou selected for the Gold Class \n\t\t\t\t";
466             system(
"PAUSE");
467         system(
"CLS");
468         amt[
2] = a * 700;
469         
char final;
470         cout<<
"\n\t\t\t\tDo you have DTcard(y/n): ";
471         cin>>final;
472         
if(final=='y')
473         {
474             
int cid;
475             cout<<
"\n\t\t\t\tEnter the card id number: ";
476             cin>>cid;
477             
if(cid==id)
478             {
479                 amt[
1]=amt[1] - (0.1*amt[1]);
480             };
481         }
482         cout<<
"\n\t\t\t\tWant to pay by Card(y/n): ";
483         
char rep;
484         cin>>rep;
485         cout<<
"\n\t\t\t\t"<<"Paying :"<<amt[2]<<"\n";
486         
if (rep=='y'||rep=='Y')
487         {
488             cout<<
"\t\t\t\tName of the card holder: ";
489             
char n[10];
490             gets(n);
491             cout<<
"\n\t\t\t\tEnter the card number: ";
492             
char Card[16];
493             gets(Card);
494             cout<<
"\n\t\t\t\tExpiry(MM/YY): ";
495             
int expirymm, expiryyy;
496             cin>>expirymm;
497             cout<<
"\n/";
498             cin>>expiryyy;
499             
while(expirymm<(timePtr->tm_mon) || expiryyy<(timePtr->tm_year + 1900)){
500                 
if(expirymm<=(timePtr->tm_mon))
501                     {
502                         cout<<
"\n\t\t\t\tEnter the month again: ";
503                         cin>>expirymm;
504                     }
505                 
if(expiryyy<(timePtr->tm_year + 1900))
506                 {
507                     cout<<
"\n\t\t\t\tPlease enter a valid year: ";
508                     cin>>expiryyy;
509                 }
510             };
511             
char password[3],vh;
512             
int h;
513             puts(
"\n\t\t\t\tEnter the CVV/CVV2: ");
514             
while (1)
515             {
516                 
if (h<0)
517                     h=
0;
518                 vh=getch();
519                 
if (vh==13)
520                     
break;
521                 
if (vh==8)
522                 {
523                     putch(NULL);
524                     putch(NULL);
525                     putch(NULL);
526                     h--;
527                     
continue;
528                 }
529                 password[h++]=vh;
530                 vh=
'*';
531                 putch(vh);
532             };
533             password[h]==
'\0';
534             }
535     };
536 }


Gõ tìm kiếm nhanh...